# Which compiler
# CC = gcc
# AR = ar
# AT = @


OUTPUT = ssd1306

# source file
# SRCS = ${wildcard *.c}
SRCS := ssd1306_demo.c
SRCS += sova.c

OBJS = $(patsubst %.c,%.o,$(SRCS))

LIBS += -lbcm2835
LIBS += -lspi
LIBS += -lolcd


# Where are include files kept
INCLUDES += -I$(PROJ_ROOT_PATH)
INCLUDES += -I$(PROJ_ROOT_PATH)/bus/spi
INCLUDES += -I$(PROJ_ROOT_PATH)/driver/userspace/ads1256
INCLUDES += -I$(PROJ_ROOT_PATH)/driver/userspace/olcd/src

# Option for development
CFLAGS = -g -O2 -Wall
# Option for release
# CFLAGS = -O -Wall


include $(PROJ_ROOT_PATH)/config.mk


$(OUTPUT): $(OBJS)
	$(AT)echo "LIBS: $(LIBS)"
	$(AT)echo "LIBS_PATH: $(LIBS_PATH)"
	$(AT)echo "BIN_PATH: $(BIN_PATH)"
	$(AT)echo "INCLUDES: $(INCLUDES)"
	$(AT)echo "@: $@"
	$(AT)$(CC) $^ -o $(BIN_PATH)$@ $(INCLUDES) $(LIBS) -L$(LIBS_PATH)
	$(AT)echo "$(OUTPUT) linking done"

$(OBJS): $(SRCS)
	$(AT)$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
	$(AT)echo "$(OBJS) compiling done"


.PHONY: clean
clean:
	$(AT)-rm -rf $(OBJS)

